package demo3;


class Person implements Cloneable{
    public int age;

    public Person(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test1 {
    public static void main(String[] args) throws CloneNotSupportedException{
        Person person1 = new Person(10);
        Person person2 = (Person)person1.clone();   //向下转型
        System.out.println(person2);
        System.out.println(person1);
    }
}
